#include <bits/stdc++.h>
using namespace std;
// 最长上升子序列
const int N = 27;
int n, m, h[N], dp[N], f[N], ans_t, ans_c;

int main()
{
	cin >> m;
	while (m--)
	{
		ans_t = ans_c = 0;
		memset(h, 0, sizeof(h));
		memset(dp, 0, sizeof(dp));
		memset(f, 0, sizeof(f));
		cin >> n;
		for (int i = 1; i <= n; ++i)
		{
			cin >> h[i];
			dp[i] = f[i] = 1;
		}
		for (int i = 2; i <= n; ++i)
			for (int j = i - 1; j; --j)
				if (h[j] <= h[i])
				{
					if ((dp[j] + 1) > dp[i])
					{
						dp[i] = dp[j] + 1;
						f[i] = f[j];
					}
					else if (dp[j] + 1 == dp[i])
						f[i] += f[j];
				}
		for (int i = 1; i <= n; ++i)
		{
			ans_t = max(ans_t, dp[i]);
		}
		for (int i = 1; i <= n; ++i)
			if (dp[i] == ans_t)
				ans_c += f[i];
		cout << ans_t << ' ' << ans_c << endl;
	}

	return 0;
}